package com.gitlab.lucky.common.dao.mapper;

import com.gitlab.lucky.common.dao.model.WeixinGzhUser;
import com.gitlab.lucky.common.mapper.AbstractMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface WeixinGzhUserMapper extends AbstractMapper<WeixinGzhUser> {
    @Select("select b.headimgurl,b.nickname,b.openid,b.subscribe_time,ss.qr_scene_str,ss.number from" +
            "(select qr_scene_str,count(qr_scene_str) as number from weixin_gzh_user where subscribe_time>#{nowTime} and platform = #{platform}  and qr_scene_str is not null and qr_scene_str!='' GROUP BY qr_scene_str HAVING count(qr_scene_str)>1 order by number desc) as ss " +
            "inner join weixin_gzh_user as b on b.openid = ss.qr_scene_str limit 0,20")
    List<WeixinGzhUser> selectInviteRanKingList(@Param("platform")Integer platform,@Param("nowTime") Long nowTime);
}